package cn.smile.controller;

import cn.smile.annotation.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据库CURD操作
 *
 * @Author: MaoSuyu
 * @User：John
 * @Date: 2019/7/4
 * @Time: 16:57
 * @Description: No Description
 */
@RestController
public class CurdController {

    /**
     * 插入
     * @return
     */
    @PostMapping("/insert")
    @RequiresPermissions("USER:INSERT")
    @RequiresRoles("admin")
    @PermissionName(permissionName = "添加权限")
    public String insert(){
        return "添加";
    }

    /**
     * 删除
     * @return
     */
    @PostMapping("/delete")
    @RequiresPermissions("USER:DELETE")
    @RequiresRoles("admin")
    @PermissionName(permissionName = "删除权限")
    public String delete(){
        return "删除";
    }

    /**
     * 更新
     * @return
     */
    @PostMapping("/update")
    @RequiresPermissions("USER:UPDATE")
    @RequiresRoles("admin")
    @PermissionName(permissionName = "更新权限")
    public String update(){
        return "更新";
    }

    /**
     * 查询
     * @return
     */
    @PostMapping("/select")
    @RequiresPermissions("USER:SELECT")
    @PermissionName(permissionName = "查询权限")
    public String select(){
        return "查询";
    }
}
